﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>AllCatagory</title>
    <link rel="stylesheet" type="text/css" href="../../Content/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="../../Content/themes/default/form.css" />
    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery-1.4.4.min.js") %>'></script>
    <script type="text/javascript" language="javascript" src='<%=Url.Content("~/Scripts/jquery.easyui.min.js") %>'></script>

    <script language="javascript" type="text/javascript">
        function deleteobj(t) {
            if (!confirm("您真的要删除项吗？"))
                return;
            var selt = $(t);
            var td = selt.parents("td");
            var tds = td.siblings("td[field=id]");
            var id = tds.children("div").text();
            $.ajax({
                url: '../Admin/DelteCatagory',
                type: 'Post',
                data: { id: id },
                timeout: 20000,
                error: function(data) {
                    alert("发生未知异常，删除失败，请您稍候再试！");
                },
                success: function(data) {
                    if (data == 1) {
                        $('#test').datagrid('reload');

                    } else {
                        alert("发生未知异常，删除失败，请您稍候再试！");
                    }
                }
            });
        }
        ///加载数据到datagrid
        function CreateDataGrid() {
            var result = $("#result");
            var width = result.width();
            var lwidth = width * 0.6;
            var rwidth = width * 0.4;
            var test = result.children('#test');
            test.datagrid({
                title: '字典项信息',
                iconCls: 'icon-save',
                width: width,
                height: 380,
                nowrap: false,
                striped: true,
                collapsible: true,
                url: '../Admin/GetCatagorys',
                loadMsg: "正在加载数据......",
                columns: [[
			        { title: '类型信息', colspan: 2 },
					{ field: 'opt', title: '操作', width: rwidth, align: 'center', rowspan: 1,
					    formatter: function(value, rec) {
					        return '<span style=" cursor: pointer;"><a  href="javascript:void(0)"  onclick="deleteobj(this)"> 删除</a></span>';
					    }
					}
				], [
					{ field: 'id', title: '', width: 0 },
					{ field: 'catagrory', title: '所属类别', width: lwidth, rowspan: 1 }
				]],
                pagination: true,
                rownumbers: false
            });
            test.datagrid('hideColumn', 'id');
        }
        $(function() {
            CreateDataGrid();
        });
    </script>

</head>
<body>
    <div id="main_body">
        <div id="result" style="border: none">
            <table id="test">
            </table>
        </div>
    </div>
</body>
</html>
